package com.atguigu.gmallre.mock.task;

import com.alibaba.fastjson.JSON;
import com.atguigu.gmallre.mock.config.AppConfig;
import com.atguigu.gmallre.mock.factory.UserSession;
import com.atguigu.gmallre.mock.log.*;
import com.atguigu.gmallre.mock.log.enums.ActionId;
import com.atguigu.gmallre.mock.log.enums.ItemType;
import com.atguigu.gmallre.mock.log.enums.PageId;
import com.atguigu.mock.util.LogUtil;
import com.atguigu.mock.util.RandomNum;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Component
@Slf4j
public class TestMockTask {


    public void  mock() {
        while (true){

            AppCommon appCommon  = AppCommon.build();

            AppStart appStart = AppStart.builder().build();
            Long ts= new Date().getTime();
            AppMain appMain = AppMain.builder().common(appCommon).start(appStart).ts(ts) .build();
            LogUtil.log(JSON.toJSONString(appMain));

            for (int i = 0; i < 5; i++) {
                AppPage appPage = AppPage.builder().page_id(PageId.good_detail).build();
                AppAction cartAction = new AppAction(ActionId.cart_add, ItemType.sku_id,  RandomNum.getRandInt(1,30)+"","","",ts);
                List<AppAction> actionList = new ArrayList<>();
                actionList.add(cartAction);

                List<AppDisplay> appDisplayList = AppDisplay.builder().pos_id(4).max_size(9).buildList();

                AppMain appMainPage = AppMain.builder().common(appCommon).page(appPage).actions(actionList).displays(appDisplayList).ts(ts) .build();

                LogUtil.log(JSON.toJSONString(appMainPage));


            }


        }


    }
}
